//===============================================================================
// Microsoft patterns & practices
// Guidance Explorer Offline Client
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================



using System;
using System.Runtime.InteropServices;

namespace GuidanceExplorer.Controls
{
    static class Win32
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int GetScrollPos(IntPtr hWnd, int nBar);

        [DllImport("user32", EntryPoint = "SendMessage")]
        private static extern IntPtr SendMessageINT(IntPtr Handle, Int32 msg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32", EntryPoint = "SendMessage")]
        private static extern IntPtr SendMessageITEM(IntPtr Handle, Int32 msg, IntPtr wParam, ref HDITEM lParam);

        public static IntPtr SendMessage(IntPtr Handle, Int32 msg, IntPtr wParam, IntPtr lParam)
        {
            return SendMessageINT(Handle, msg, wParam, lParam);
        }

        public static IntPtr SendMessage(IntPtr Handle, Int32 msg, IntPtr wParam, ref HDITEM lParam)
        {
            return SendMessageITEM(Handle, msg, wParam, ref lParam);
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct HDITEM
        {
            public Int32 mask;
            public Int32 cxy;
            [MarshalAs(UnmanagedType.LPTStr)]
            public String pszText;
            public IntPtr hbm;
            public Int32 cchTextMax;
            public Int32 fmt;
            public Int32 lParam;
            public Int32 iImage;
            public Int32 iOrder;
        };

        //Parameters for ListView-Headers
        public const Int32 HDI_FORMAT = 0x0004;
        public const Int32 HDI_IMAGE = 0x0020;
        public const Int32 HDI_DI_SETITEM = 0x0040;

        public const Int32 HDF_LEFT = 0x0000;
        const Int32 HDF_RIGHT = 0x0001;
        const Int32 HDF_CENTER = 0x0002;
        const Int32 HDF_JUSTIFYMASK = 0x0003;
        public const Int32 HDF_STRING = 0x4000;
        public const Int32 HDF_BITMAP_ON_RIGHT = 0x1000;
        public const Int32 HDF_IMAGE = 0x0800;
        const Int32 HDF_SORTUP = 0x0400;
        const Int32 HDF_SORTDOWN = 0x0200;

        //Parameters for ListViews
        const Int32 LVM_FIRST = 0x1000;
        public const Int32 LVM_GETHEADER = LVM_FIRST + 31;

        //Messages for ListView-Headers
        const Int32 HDM_FIRST = 0x1200;
        public const Int32 HDM_SETITEM = HDM_FIRST + 12;
        public const Int32 HDM_SETIMAGELIST = HDM_FIRST + 8;
    }
}

